package moonlit.chill.pay.factory;

import lombok.Getter;
import moonlit.chill.pay.constants.PayChannel;
import moonlit.chill.pay.constants.PayStrategySuffix;
import moonlit.chill.pay.constants.PayType;

/**
 * @author MoonlitChill
 * @date 2024/4/23 16:34
 */
@Getter
public enum PayStrategyEnum {

    WX_PC_PAY(PayType.WX + "-" + PayChannel.PC, "wxPcPayStrategy"),

    WX_CODE_PAY(PayType.WX + "-" + PayChannel.CODE, "wxCodePayStrategy"),

    WX_MINI_PAY(PayType.WX + "-" + PayChannel.MINI, "wxMiniPayStrategy"),

    WX_QUERY(PayType.WX + PayStrategySuffix.QUERY, "wxQueryStrategy"),

    WX_REFUND_QUERY(PayType.WX + PayStrategySuffix.REFUND_QUERY, "wxRefundQueryStrategy"),

    WX_REFUND(PayType.WX + PayStrategySuffix.REFUND, "wxRefundStrategy"),

    WX_NOTIFY(PayType.WX + PayStrategySuffix.NOTIFY, "wxNotifyStrategy"),

    WX_BILL(PayType.WX + PayStrategySuffix.BILL, "wxBillStrategy"),

    ALI_PC_PAY(PayType.ALI + "-" + PayChannel.PC, "aliPcPayStrategy"),

    ALI_H5_PAY(PayType.ALI + "-" + PayChannel.WAP, "aliH5PayStrategy"),

    ALI_CODE_PAY(PayType.ALI + "-" + PayChannel.CODE, "aliCodePayStrategy"),

    ALI_MINI_PAY(PayType.ALI + "-" + PayChannel.MINI, "aliMiniPayStrategy"),

    ALI_QUERY(PayType.ALI + PayStrategySuffix.QUERY, "aliQueryPayStrategy"),

    ALI_REFUND_QUERY(PayType.ALI + PayStrategySuffix.REFUND_QUERY, "aliRefundQueryPayStrategy"),

    ALI_REFUND(PayType.ALI + PayStrategySuffix.REFUND, "aliRefundStrategy"),

    ALI_NOTIFY(PayType.ALI + PayStrategySuffix.NOTIFY, "aliNotifyStrategy"),

    ALI_BILL(PayType.ALI + PayStrategySuffix.BILL, "aliBillStrategy");

    private final String code;

    private final String name;

    PayStrategyEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static PayStrategyEnum getPayStrategyEnum(final String code) {
        PayStrategyEnum[] payEnums = PayStrategyEnum.values();
        if (code != null) {
            for (PayStrategyEnum payEnum : payEnums) {
                if (payEnum.code.equals(code)) {
                    return payEnum;
                }
            }
        }
        return null;
    }

}
